{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%pylab inline\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "import skrf\n",
    "skrf.stylely()\n",
    "\n",
    "import sys; sys.path.insert(0, r\"C:\\Coding\\Python\\scikit-rf\\qtapps\")  # <-- if you don't have skrf_qtwidgets in your path\n",
    "import skrf_qtwidgets\n",
    "# from skrf_qtwidgets.analyzers.keysight_pna.analyzer import Analyzer\n",
    "from skrf_qtwidgets.analyzers.analyzer_agilent_n5247a import Analyzer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "nwa = Analyzer(address=16, interface=\"GPIB\")\n",
    "nwa.idn"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### OPTIONAL METHODS TO OVERRIDE FOR SKRF_QTWIDGETS\n",
    "* init - setup the instrument resource (i.e., pyvisa)\n",
    "* get_twoport_ntwk  -- *requires implementing get_snp_network*\n",
    "* get_oneport_ntwk  -- *requires implementing get_snp_network*\n",
    "* enter/exit - for using python's with statement\n",
    "\n",
    "`\n",
    "with Analyzer(\"GPIB0::16::ISNTR\") as nwa:\n",
    "    ntwk = nwa.measure_twoport_ntwk()\n",
    "`\n",
    "\n",
    "### METHODS THAT MUST BE IMPLEMENTED FOR SKRF_QTWIDGETS\n",
    "* get_traces\n",
    "* get_list_of_traces\n",
    "* get_snp_network\n",
    "* get_switch_terms\n",
    "* set_frequency_sweep\n",
    "\n",
    "### OPTIONAL CLASS PROPERTIES TO OVERRIDE\n",
    "* DEFAULT_VISA_ADDRESS\n",
    "* NAME\n",
    "* NPORTS\n",
    "* NCHANNELS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "nwa.set_frequency_sweep(10, 40, 401, f_unit='GHz')  # Ku-Band"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "ntwk = nwa.get_oneport_ntwk(port=1, sweep=False)\n",
    "ntwk.plot_s_db()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "ntwk = nwa.get_twoport_ntwk(ports=(1,2), sweep=True)\n",
    "ntwk.plot_s_db()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fwd, rev = nwa.get_switch_terms(ports=(1, 2))\n",
    "fwd.plot_s_db()\n",
    "rev.plot_s_db()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "trace_list = nwa.get_list_of_traces()\n",
    "trace_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "traces = nwa.get_traces(trace_list[0:2])\n",
    "for trace in traces:\n",
    "    trace.plot_s_db()"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
